package com.aspose.cells;

import java.util.HashMap;

class zaka {
   private zoz a = null;
   private Worksheet b = null;
   private zpa c;
   private HashMap d;
   private boolean e;
   private zajm f = null;
   private static final com.aspose.cells.b.c.a.za g = new com.aspose.cells.b.c.a.za(new String[]{"cols", "sheetData", "n", "s", "str", "e", "b"});

   zaka(zoz var1, zpa var2, boolean var3) {
      this.a = var1;
      this.c = var2;
      this.b = var2.d;
      this.d = new HashMap();
      this.e = var3;
   }

   void a(zcfw var1) throws Exception {
      this.e(var1);
      if (!var1.n()) {
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else {
               switch(g.a(var1.p())) {
               case 0:
                  this.c(var1);
                  break;
               case 1:
                  this.b(var1);
                  break;
               default:
                  var1.a();
               }
            }
         }

      }
   }

   private void b(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         int var2 = -1;
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else {
               if (!"row".equals(var1.p())) {
                  var1.a();
                  throw new CellsException(6, "Invalid sheetData sub Element " + var1.p());
               }

               var2 = this.a(var1, var2);
            }
         }

         var1.h();
      }
   }

   private int a(zcfw var1, int var2) throws Exception {
      int var3 = var2 + 1;
      int var4 = -1;
      double var5 = -1.0D;
      boolean var7 = false;
      boolean var8 = false;
      boolean var9 = false;
      boolean var10 = false;
      short var11 = -1;
      boolean var12 = false;
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            if ("r".equals(var1.p())) {
               var3 = zase.C(var1.s()) - 1;
            } else if ("s".equals(var1.p())) {
               var4 = zase.C(var1.s());
            } else if ("customFormat".equals(var1.p()) && "1".equals(var1.s())) {
               var7 = true;
            } else if ("ht".equals(var1.p())) {
               var5 = zase.B(var1.s());
               if (var5 > 409.5D) {
                  var5 = 409.5D;
               }

               var10 = true;
            } else if ("customHeight".equals(var1.p()) && "1".equals(var1.s())) {
               var8 = true;
            } else if ("hidden".equals(var1.p()) && "1".equals(var1.s())) {
               var9 = true;
            } else if ("outlineLevel".equals(var1.p())) {
               var11 = zase.E(var1.s());
            } else if ("collapsed".equals(var1.p()) && "1".equals(var1.s())) {
               var12 = true;
            }
         }
      }

      Row var13 = this.b.getCells().getRows().a(var3, 16);
      if (var4 != -1 && var7) {
         Object var14 = this.a.d.get(var4);
         if (var14 == null) {
            throw new CellsException(6, "Invalid row style Idx, rowid:" + var3);
         }

         var13.e((Integer)var14);
         var13.c(true);
      }

      var13.b(var12);
      if (var11 != -1) {
         var13.a((byte)var11);
      }

      if (var10) {
         if (var8) {
            this.b.getCells().setRowHeight(var3, var5);
         } else {
            var13.f((int)(var5 * 20.0D));
            var13.setHeightMatched(true);
         }
      }

      var13.setHidden(var9);
      if (var1.n()) {
         var1.a();
         return var3;
      } else {
         int var15 = -1;
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("c".equals(var1.p())) {
               var15 = this.a(var1, var13, var3, var15);
            } else {
               var1.a();
            }
         }

         var1.h();
         return var3;
      }
   }

   void a(zajm var1) {
      this.f = var1;
   }

   private int a(zcfw var1, Row var2, int var3, int var4) throws Exception {
      int var5 = -1;
      String var6 = "n";
      String var7 = null;
      if (var1.m()) {
         while(true) {
            if (!var1.l()) {
               var1.k();
               break;
            }

            if ("r".equals(var1.p())) {
               var7 = var1.s();
            } else if ("s".equals(var1.p())) {
               var5 = zase.C(var1.s());
            } else if ("t".equals(var1.p())) {
               var6 = var1.s();
            }
         }
      }

      int var8 = var4 + 1;
      if (var7 != null) {
         byte var9 = 0;
         int[] var10 = new int[]{var9};
         int[] var11 = new int[]{var8};
         CellsHelper.a(var7, var10, var11);
         int var19 = var10[0];
         var8 = var11[0];
         if (var3 != var19 || var8 < var4 + 1) {
            throw new CellsException(6, "Invalid cell name");
         }
      }

      Cell var20 = var2.a(this.b.getCells().getRows(), var8, false, false, false);
      if (var5 != -1) {
         int var21 = (Integer)this.a.d.get(var5);
         var20.b(var21);
      } else {
         var20.b(15);
      }

      if (var1.n()) {
         if (var20.z()) {
            var20.e();
         }

         var1.a();
         return var8;
      } else {
         boolean var22 = true;
         var1.d();

         while(true) {
            while(var1.r() != 4) {
               var1.j();
               if (var1.r() != 1) {
                  var1.a();
               } else {
                  String var24;
                  if (this.e && "f".equals(var1.p())) {
                     var22 = false;
                     var24 = var1.a("t");
                     String var12;
                     if (!"array".equals(var24) && !"shared".equals(var24)) {
                        var12 = var1.i();
                        var20.setFormula("=" + var12);
                     } else {
                        var12 = var1.a("ref");
                        String var13 = var1.a("si");
                        String var14 = var1.i();
                        if (var12 != null && var14 != null) {
                           if ("array".equals(var24)) {
                              byte var25 = 0;
                              byte var16 = 0;
                              int[] var17 = new int[]{var25};
                              int[] var18 = new int[]{var16};
                              a(var12, var17, var18);
                              int var26 = var17[0];
                              int var28 = var18[0];
                              var20.a("=" + var14, var26, var28);
                           } else if ("shared".equals(var24)) {
                              CellArea var27 = (CellArea)CellArea.a(var12, true);
                              byte[] var29 = var20.a("=" + var14, var27);
                              if (var13 != null) {
                                 this.d.put(var13, var29);
                              }
                           }
                        } else if ("shared".equals(var24) && var13 != null) {
                           Object var15 = this.d.get(var13);
                           if (var15 != null) {
                              var20.c((byte[])((byte[])var15));
                           }
                        }
                     }
                  } else if ("v".equals(var1.p())) {
                     if (var22 && var20.z()) {
                        var20.e();
                     }

                     var24 = var1.i();
                     if (var24 != null && !"".equals(var24)) {
                        this.a(var20, var24, var6);
                     }
                  } else if ("is".equals(var1.p())) {
                     if ("inlineStr".equals(var6) && this.f != null) {
                        zayy var23 = this.f.b(var1);
                        var20.a(4, var23, false);
                     } else {
                        var1.a();
                     }
                  } else {
                     var1.a();
                  }
               }
            }

            var1.h();
            return var8;
         }
      }
   }

   private void a(Cell var1, String var2, String var3) {
      switch(g.a(var3)) {
      case 2:
         double var4 = zase.B(var2);
         var1.a(1, var4);
         break;
      case 3:
         int var6 = zase.C(var2);
         var1.a(4, this.a.a.getWorksheets().g.a(var6), false);
         break;
      case 4:
         if (!var1.f()) {
            var1.putValue(var2);
         } else {
            var1.a(4, var2);
         }
         break;
      case 5:
         var1.a(3, zsk.a(var2));
         break;
      case 6:
         boolean var7 = "1".equals(var2);
         var1.a(2, var7);
      }

   }

   private void c(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("col".equals(var1.p())) {
               this.d(var1);
            } else {
               var1.a();
            }
         }

         var1.h();
      }
   }

   private void d(zcfw var1) throws Exception {
      if (!var1.m()) {
         var1.a();
      } else {
         int var2 = -1;
         int var3 = -1;
         int var4 = -1;
         short var5 = -1;
         double var6 = -1.0D;
         boolean var8 = false;
         boolean var9 = false;
         boolean var10 = false;
         boolean var11 = false;

         while(true) {
            while(var1.l()) {
               if ("min".equals(var1.p())) {
                  var2 = zase.C(var1.s()) - 1;
                  if (var3 == -1) {
                     var3 = var2;
                  }
               } else if ("max".equals(var1.p())) {
                  var3 = zase.C(var1.s()) - 1;
               } else if ("width".equals(var1.p())) {
                  var6 = zase.B(var1.s());
                  var8 = true;
               } else if ("style".equals(var1.p())) {
                  var4 = zase.C(var1.s());
               } else if ("hidden".equals(var1.p()) && "1".equals(var1.s())) {
                  var9 = true;
               } else if ("customWidth".equals(var1.p()) && "1".equals(var1.s())) {
                  var10 = true;
               } else if ("outlineLevel".equals(var1.p())) {
                  var5 = zase.E(var1.s());
               } else if ("collapsed".equals(var1.p()) && "1".equals(var1.s())) {
                  var11 = true;
               }
            }

            var1.k();
            var1.a();

            for(int var12 = var2; var12 <= var3 && var12 <= 255; ++var12) {
               Column var13 = this.b.getCells().getColumns().get(var12);
               if (var8 && var10) {
                  this.b.getCells().setColumnWidthPixel(var12, (int)(var6 * (double)this.a.a.getWorksheets().I()));
               }

               if (var4 != -1) {
                  int var14 = (Integer)this.a.d.get(var4);
                  var13.c(var14);
               } else {
                  var13.c(15);
               }

               if (var5 != -1) {
                  var13.a((byte)var5);
               }

               var13.setHidden(var9);
               var13.b(var11);
            }

            return;
         }
      }
   }

   private void e(zcfw var1) throws Exception {
      var1.j();
      if (var1.r() != 1 || !"worksheet".equals(var1.p())) {
         throw new CellsException(6, "Absent root element: worksheet");
      }
   }

   private static void a(String var0, int[] var1, int[] var2) {
      int var3;
      for(var3 = 0; var3 < var0.length() && var0.charAt(var3) != ':'; ++var3) {
         ;
      }

      if (var3 == var0.length()) {
         var1[0] = 1;
         var2[0] = 1;
      } else {
         byte var4 = 0;
         byte var5 = 0;
         byte var6 = 0;
         byte var7 = 0;
         int[] var8 = new int[]{var4};
         int[] var9 = new int[]{var6};
         CellsHelper.a(var0.substring(0, 0 + var3), var8, var9);
         int var12 = var8[0];
         int var14 = var9[0];
         int[] var10 = new int[]{var5};
         int[] var11 = new int[]{var7};
         CellsHelper.a(var0.substring(var3 + 1), var10, var11);
         int var13 = var10[0];
         int var15 = var11[0];
         var1[0] = var13 - var12 + 1;
         var2[0] = var15 - var14 + 1;
      }
   }
}
